<?php


namespace App\Api\Repositories;


use App\Api\Models\CmcGoodsCollection;

class CollectionRepositorie
{
    //检验是否收藏
    static public function isCollection($gid,$uid)
    {
        return CmcGoodsCollection::collection($gid,$uid);
    }
    //检验收藏状态
    static public function isStatus($gid,$uid)
    {
        return CmcGoodsCollection::statusCollection($gid,$uid);
    }
    //收藏
    static public function successCollection($gid,$uid)
    {
        //获取ID
        $id = CmcGoodsCollection::getId($gid,$uid);
        return CmcGoodsCollection::upCollection($id,1);
    }
    //添加收藏
    static public function addCollection($gid,$uid)
    {
        $data = [
            'goods_id'=>(int)$gid,
            'uid'=>(int)$uid,
            'status'=>1
        ];
        return CmcGoodsCollection::add($data);
    }
    //取消收藏
    static public function cancellationCollection($gid,$uid)
    {
        //获取ID
        $id = CmcGoodsCollection::getId($gid,$uid);
        return CmcGoodsCollection::upCollection($id,0);
    }
}